//
//  XS_MineFeedBackItemCell.swift
//  XueDao
//
//  Created by Mac on 2020/12/17.
//

import UIKit

class XS_MineFeedBackItemCell: UICollectionViewCell {

    @IBOutlet weak var contentLabel: UILabel!
    @IBOutlet weak var timeLabel: UILabel!
    
    @IBOutlet weak var firstImageView: UIImageView!
    @IBOutlet weak var secondImageView: UIImageView!
    @IBOutlet weak var thirdImageView: UIImageView!
    @IBOutlet weak var fourthImageView: UIImageView!
    @IBOutlet weak var numberLabel: UILabel!
    var _model : XS_FeedBackItemModel!
    public var model : XS_FeedBackItemModel!{
        set{
            _model = newValue
            //设置数据
            contentLabel.text = newValue.sendContent
            timeLabel.text = newValue.sendTime
            let count = newValue.imgList.count
            if count > 0 {
                firstImageView.isHidden = false
                firstImageView.sd_setImage(with: URL.init(string: newValue.imgList.first ?? ""), completed: nil)
                if count > 1 {
                    secondImageView.isHidden = false
                    secondImageView.sd_setImage(with: URL.init(string: newValue.imgList[1]), completed: nil)
                    if count > 2 {
                        thirdImageView.isHidden = false
                        thirdImageView.sd_setImage(with: URL.init(string: newValue.imgList[2]), completed: nil)
                        if count > 3 {
                            fourthImageView.isHidden = false
                            fourthImageView.sd_setImage(with: URL.init(string: newValue.imgList[3]), completed: nil)
                            if count > 4 {
                                numberLabel.isHidden = false
                                numberLabel.text = "+"+String(count - 4)
                            }
                        }
                    }
                }
            }
        }
        get{
            return _model
        }
    }
    
    class func getCellHeight(model : XS_FeedBackItemModel) -> CGFloat{
        let contentStr = model.sendContent as NSString
        return 136 + contentStr.boundingRect(with: CGSize.init(width: .screenWidth - 16 * 4, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14)], context: nil).height
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        layer.cornerRadius = 4
        clipsToBounds = true
    }

}
